import handlers from "./utils/handlers";
import { isObject, isProxy } from "./utils/components.js";
const targetMap = new WeakMap();
export function reactive(target) {
  if (!isObject(target)) {
    //如果不是对象,直接返回
    return target;
  }
  if (isProxy(target)) {
    //如果已被标记,则直接返回
    return target;
  }
  if (targetMap.has(target)) {
    //如果存在,则直接返回
    return target.get(target);
  }
  const saveProxy = new Proxy(target, handlers);

  targetMap.set(target, Proxy);

  return saveProxy;
}
